package com.nikkerball.apps.darkhorse.model.change;

import com.nikkerball.apps.darkhorse.model.base.BaseObject;
import org.hibernate.annotations.Cascade;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.List;

import static org.hibernate.annotations.CascadeType.*;

/**
 * Represents a Change to any Data
 *
 * @author marius (created on 2010-12-12)
 */

@Entity
@Table(name = "ChangeEvent")
public class ChangeEvent extends BaseObject {

    // ----- instance fields -----

    private String changeType;

    private List<ChangeValue> changeValues;

    private int objectId;

    private String objectType;

    // ----- public methods -----

    @Column(nullable = false)
    public String getChangeType() {
        return this.changeType;
    }

    public void setChangeType(String changeType) {
        this.changeType = changeType;
    }

    @OneToMany(mappedBy = "changeEvent")
    @Cascade({MERGE, PERSIST, SAVE_UPDATE, DETACH, DELETE})
    public List<ChangeValue> getChangeValues() {
        return this.changeValues;
    }

    public void setChangeValues(List<ChangeValue> changeValues) {
        this.changeValues = changeValues;
    }

    @Column(nullable = false)
    public int getObjectId() {
        return this.objectId;
    }

    public void setObjectId(int objectId) {
        this.objectId = objectId;
    }

    @Column(nullable = false)
    public String getObjectType() {
        return this.objectType;
    }

    public void setObjectType(String objectType) {
        this.objectType = objectType;
    }

}
